package main

import "fmt"

func main() {
	var A, B int
	fmt.Scanf("%d %d", &A,&B)
	arrA := make([]int, A)
	arrB := make([]int, B)
	for i := range arrA {
		fmt.Scanf("%d", &arrA[i])
	}
	for j := range arrB {
		fmt.Scanf("%d", &arrB[j])
	}
	// fmt.Println(arrB)
	// 先从A拿糖果还是先从B 拿糖果
	// 先从A拿
	indexA := 0
	sumA := 0
	maxA := 0
	for i := 0; i < len(arrA) * 2; i ++ {
		if i > len(arrB) * 2 {
			indexA = i
			break
		}
		if i % 2 == 0 {
			sumA += arrA[i / 2]
			if sumA > maxA {
				maxA = sumA
			}
		}else {
			sumA += arrB[i / 2]
			if sumA > maxA {
				maxA = sumA
			}
		}
	}
	if indexA != 0 {
		// 计算A中剩余的
		for indexA < len(arrA) * 2 {
			sumA += arrA[indexA / 2]
			if sumA > maxA {
				maxA = sumA
			}
			indexA ++
		}
	}
	// fmt.Println(maxA)
	// 先从B拿
	indexB := 0
	sumB := 0
	maxB := 0
	for i := 0; i < len(arrB) * 2; i ++ {
		if i > len(arrA) * 2 {
			indexB = i
			break
		}
		if i % 2 == 0 {
			sumB += arrB[i / 2]
			if sumB > maxB {
				maxB = sumB
			}
		}else {
			sumB += arrA[i / 2]
			if sumB > maxB {
				maxB = sumB
			}
		}
	}
	if indexB != 0 {
		// 计算A中剩余的
		for indexB < len(arrB) * 2 {
			sumB += arrB[indexB / 2]
			if sumB > maxB {
				maxB= sumB
			}
			indexB ++
		}
	}
	if maxA > maxB {
		fmt.Println(maxA)
	}else {
		fmt.Println(maxB)
	}
}
